package com.ahui.test;

import com.alibaba.fastjson.JSONObject;
import com.athui.bean.ColumnMetaData;
import com.athui.bean.DataType;
import com.athui.service.FileExplorerService;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @description: TODO
 * @autor: zhangzhonghui
 * @create: 2024-08-23 17:50
 * @Version: 1.0
 */
public class FileExplorerServiceTest2 extends FileExplorerService<JSONObject> {


    public FileExplorerServiceTest2(String filePath) {
        super(filePath);
    }

    @Override
    public Collection<ColumnMetaData> getColumnMetaDataList(Collection<ColumnMetaData> collect) {

        ColumnMetaData id =new ColumnMetaData();
        id.setColumnName("ID");
        id.setColumnCode("id");
        id.setIndex("id");
        id.setTypeLabel(DataType.NUMERICAL);
        collect.add(id);

        ColumnMetaData name =new ColumnMetaData();
        name.setColumnName("NAME");
        name.setColumnCode("name");
        name.setIndex("name");
        name.setTypeLabel(DataType.TEXT);
        collect.add(name);

        return collect;
    }

    @Override
    public JSONObject transformBySourceType(String input) {
        JSONObject jsonObject = JSONObject.parseObject(input);
        return jsonObject;
    }

    @Override
    public Object transformByValue(String index, JSONObject row) {
        return row.get(index);
    }

    public static void main(String[] args) throws Exception {
        FileExplorerServiceTest2 fileExplorerServiceTest2 = new FileExplorerServiceTest2("/Users/zhangzhonghui/Documents/project/java/data_explorer_dev/src/main/resources/tmp/file2.txt");

        fileExplorerServiceTest2.run();
    }
}
